#include <iostream>
using namespace std;

/*
    1.Time类(时分秒三个成员)重载加法，要求判断处理，小时超过24，分钟、秒超过60
*/

class Time
{
public:
    Time(int h = 0, int m = 0, int s = 0)
    {
        if (h >= 24)
        {
            h = h % 24;
        }
        if (m >= 60)
        {
            m = m % 60;
        }
        if (s >= 60)
        {
            s = s % 60;
        }
        hour = h;
        minute = m;
        second = s;
    }

    Time operator+(Time &t)
    {
        int h = hour + t.hour;
        int m = minute + t.minute;
        int s = second + t.second;
        if (s >= 60)
        {
            m++;
            s -= 60;
        }
        if (m >= 60)
        {
            h++;
            m -= 60;
        }
        if (h >= 24)
        {
            h -= 24;
        }
        return Time(h, m, s);
    }

    void getTime()
    {
        cout << hour << " " << minute << " " << second << endl;
    }

private:
    int hour;
    int minute;
    int second;
};

int main()
{
    Time t1(10, 20, 30);
    Time t2(2, 30, 40);

    Time t3 = t1 + t2;
    t3.getTime();
    return 0;
}